package com.envper.controller.auth;

import com.envper.mysql.domain.Result;
import com.envper.mysql.domain.Status;
import com.envper.mysql.domain.dto.PermDto;
import com.envper.common.service.PermService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequiredArgsConstructor
@RestController
@RequestMapping("/auth/perm")
public class PermController {

    private final PermService permService;

    @PostMapping("/add")
    public Result<String> addPerm(@RequestBody PermDto perm) {
        permService.savePerm(perm);
        return Result.ok(Status.PERMSAVESUCCESS);
    }

    @GetMapping("/list")
    public Result<List<PermDto>> getPermList() {
        List<PermDto> permList = permService.getPermList();
        return Result.ok(Status.SUCCESS, permList);
    }


}
